package com.google.code.coma.gui.dialog;

import com.google.code.coma.domain.Part;
import com.google.code.coma.gui.util.ImageUtil;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.effect.Reflection;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

/**
 * @author Dominik Strasser, dominikstr@gmail.com
 */
public class PartDialog extends Stage {
	public PartDialog(Part part) {
		initModality(Modality.APPLICATION_MODAL);
		initStyle(StageStyle.UTILITY);
		setTitle("Part " + part.getType());
		setWidth(340);
		setHeight(200);
		BorderPane border = new BorderPane();
		Scene scene = new Scene(border);
		ImageView imageView = new ImageView(ImageUtil.getImage(part.getType()));
		Reflection r = new Reflection();
		r.setFraction(0.7);
		imageView.setEffect(r);
		border.setLeft(imageView);
		VBox box = new VBox();
		box.getChildren().add(new Label(" ID: " + part.getId()));
		box.getChildren().add(new Label(" Created by: " + part.getCreator()));
		box.getChildren().add(new Label(" Works: " + !part.isBroken()));
		border.setCenter(box);
		setScene(scene);
		show();
	}
}
